package com.huwaiwai.sort;

import com.google.common.collect.Lists;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * Created by hww on 2018/12/7 1:22 PM.
 */
public class Test {
    public static void main(String [] args) {
        int times = 100000;
        List<Integer> list = Lists.newArrayList();
        for (int i = times; i > 0; i--) {
            list.add(i);
        }
//        for (int i = 0; i < times; i++) {
//            list.add(i);
//        }
        Collections.shuffle(list);
        int[] a = new int[times];
        int[] b = new int[times];
        int[] c = new int[times];
        int[] d = new int[times];
        int[] e = new int[times];
        int[] f = new int[times];
        int[] g = new int[times];


        for (int i = 0; i < times; i++) {
            a[i] = list.get(i);
            b[i] = list.get(i);
            c[i] = list.get(i);
            d[i] = list.get(i);
            e[i] = list.get(i);
            f[i] = list.get(i);
            g[i] = list.get(i);
        }
        System.out.println("start.....");

//        long startV1 = System.currentTimeMillis();
//        BubbleSort.bubbleSortV1(a);
//        System.out.println("冒泡排序V1 -- " + (System.currentTimeMillis() - startV1) + "ms");
//
//        long startV2 = System.currentTimeMillis();
//        BubbleSort.bubbleSortV2(b);
//        System.out.println("冒泡排序V2 -- " + (System.currentTimeMillis() - startV2) + "ms");

        long startV4 = System.currentTimeMillis();
        QuickSort.quickSort(d, times);
        System.out.println("快速排序V-官方 -- " + (System.currentTimeMillis() - startV4) + "ms");

        long startV3 = System.currentTimeMillis();
        InsertionSort.insertionSort(c);
        System.out.println("插入排序V1 -- " + (System.currentTimeMillis() - startV3) + "ms");

        long startV5 = System.currentTimeMillis();
        Arrays.sort(e);
        System.out.println("Arrays.sort -- " + (System.currentTimeMillis() - startV5) + "ms");

        long startV6 = System.currentTimeMillis();
        SelectionSort.selectionSort(f);
        System.out.println("选择排序V1 -- " + (System.currentTimeMillis() - startV6) + "ms");

        long startV7 = System.currentTimeMillis();
        MyQuickSort.quickSort(g);
        System.out.println("快速V1 -- " + (System.currentTimeMillis() - startV7) + "ms");
//        System.out.println(Arrays.toString(g));


        /*
            times = 20000;
            冒泡排序V1 -- 1315ms
            冒泡排序V2 -- 667ms
            冒泡排序V3 -- 604ms
            插入排序V1 -- 37ms
            Arrays.sort -- 4ms
            选择排序V1 -- 53ms

            time = 50000;
            冒泡排序V1 -- 5911ms
            冒泡排序V2 -- 4126ms
            冒泡排序V3 -- 4132ms
            插入排序V1 -- 176ms
            Arrays.sort -- 7ms
            选择排序V1 -- 302ms

            times = 50000  完全倒序的数组
            冒泡排序V1 -- 3675ms
            冒泡排序V2 -- 873ms
            冒泡排序V3 -- 899ms
            插入排序V1 -- 257ms
            Arrays.sort -- 1ms
            选择排序V1 -- 762ms
         */

    }
}
